<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        html,body{
            width: 100%;
            height: 100%;
        }
        div{
            width: 200px;
            height: 200px;
            background-color: black;
            margin: auto;
            color: white;
            border: 20px solid black;
        }
        p{
            margin: 10px 10px;
            
        }
    </style>
</head>
<body>
    <div id="box">
       <p>鼠标移入改变样式，移出恢复</p> 
    </div>
</body>
<script>
    var box = document.getElementById('box')
    box.onmouseenter =function(){
        box.style.cssText = "border-color:red;color:red"
    }
    box.onmouseleave =function(){
        box.style.cssText = "border-color:black;color:white"
    }
</script>
</html>